package UDPEcho;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDicSever extends UDPEchoServer {
    private HashMap<String,String> hashMap = new HashMap<>();

    public UdpDicSever(int port) throws SocketException {
        super(port);

        hashMap.put("cat","小猫");
        hashMap.put("dog","小狗");
        hashMap.put("chicken","小坤");
        //此处可以无限添加英汉键值对
    }
    //start完全继承自父类即可
    //process方法要进行重写，加入咱们自己的业务逻辑，进行翻译

    @Override
    public String process(String request) {
        return hashMap.getOrDefault(request,"您查找的单词不存在");
    }

    public static void main(String[] args) throws IOException {
        UdpDicSever udpDicSever = new UdpDicSever(9090);
        udpDicSever.start();
    }
}
